/*
 * MainWindow.java
 *
 * Created on 4 de noviembre de 2006, 21:36
 */

package cheers.gui.main;

import cheers.gui.IApplicationFrame;
import cheers.gui.IModuleFrame;

/**
 *
 * @author  santiago
 */
public class MainWindow extends javax.swing.JFrame implements IApplicationFrame {
    
    /** Creates new form MainWindow */
    public MainWindow() {
        initComponents();
    }
    
    private IModuleFrame barCRUD = null;
    private String applicationName = "";
    private String applicationVersion = "";

    public void setApplicationVersion(String version) {
        applicationVersion = version;
        changeTitle();
    }

    public void setApplicationName(String name) {
        this.applicationName = name;
    }
    
    //<editor-fold defaultstate="collapsed" desc=" Spring Dependency Injection Setters ">
    public void setBarCRUD( IModuleFrame form) {
        this.barCRUD = form;
    }

    //</editor-fold>
    
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        menuBarCRUD = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JSeparator();
        menuExit = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        jMenu1.setText("Modules");
        menuBarCRUD.setText("Bar CRUD");
        menuBarCRUD.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuBarCRUDActionPerformed(evt);
            }
        });

        jMenu1.add(menuBarCRUD);

        jMenu1.add(jSeparator1);

        menuExit.setText("Exit");
        menuExit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuExitActionPerformed(evt);
            }
        });

        jMenu1.add(menuExit);

        jMenuBar1.add(jMenu1);

        setJMenuBar(jMenuBar1);

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 206, Short.MAX_VALUE)
        );
        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void menuBarCRUDActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuBarCRUDActionPerformed
        barCRUD.run();
    }//GEN-LAST:event_menuBarCRUDActionPerformed

    private void menuExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuExitActionPerformed
        this.dispose();
        System.exit(0);
    }//GEN-LAST:event_menuExitActionPerformed

    public void run() {
        setVisible(true);
    }

    private void changeTitle() {
        this.setTitle(applicationName + " - Version: " + applicationVersion);
    }

    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JMenuItem menuBarCRUD;
    private javax.swing.JMenuItem menuExit;
    // End of variables declaration//GEN-END:variables
    
}
